home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #46 (Jul 89) / Basic Source / GETRESMENU.S < prev    next >
Text File  |  1989-05-17  |  2KB  |  58 lines

  1. 'V
  2. 'S
  3. 'GETRESMENU function By Charles Stricklin
  4. 'Modified by Dave Kelly for MacTutor, May, 1989
  5.  
  6. 'This function creates a ZBasic menu from a MENU resource.
  7. 'The result given is boolean; true if the task is accomplished,
  8. 'false if there's a problem (i.e. the resource doesn't exist, etc.)
  9.  
  10. ' resourceID is the resource ID of the menu resource to be used.
  11. '  menuNumber is the ZBasic number of the menu to be created.
  12.  
  13. LONG FN GETRESMENU(ResourceID, MenuNumber)
  14.     DEFSTR LONG
  15.     Done=0
  16.     FALSE=0
  17.     MenuBlkSize=14
  18.     Title$=""
  19.     MyHandle&=FN GETRESOURCE(CVI("MENU"),ResourceID)
  20.     LONG IF FN RESERROR=FALSE
  21.         MyPointer&=USR 3(MyHandle&)
  22.         EnableFlags&=PEEK LONG(MyPointer&+10)
  23.         State=VAL(MID$(BIN$(EnableFlags&),32,1))
  24.         LengthTitle=PEEK(MyPointer&+MenuBlkSize)
  25.         FOR Character=1 TO LengthTitle
  26.             Title$=Title$+CHR$(PEEK(MyPointer&+MenuBlkSize+Character))
  27.         NEXT
  28.         MENU MenuNumber,0,State,Title$
  29.         Offset&=MenuBlkSize+LengthTitle+1
  30.         DO
  31.             MenuItem=MenuItem+1:Title$=""
  32.             LengthTitle=PEEK(MyPointer&+Offset&)
  33.             FOR Character=1 TO LengthTitle
  34.                 Title$=Title$+CHR$(PEEK(MyPointer&+Offset&+Character))
  35.             NEXT
  36.             Offset&=Offset&+LengthTitle+1
  37.             IconNumber&=PEEK(MyPointer&+Offset&)
  38.             IF IconNumber& THEN Title$=Title$+"^"+RIGHT$(STR$(IconNumber&),1)
  39.             CommandKey=PEEK(MyPointer&+Offset&+1)
  40.             IF CommandKey THEN Title$=Title$+"/"+CHR$(CommandKey)
  41.             MarkChar = PEEK(MyPointer&+Offset&+2)
  42.             IF MarkChar THEN Title$=Title$+"!"+CHR$(MarkChar)
  43.             CharacterStyle=PEEK(MyPointer&+Offset&+3)
  44.             IF FN BITTST(CharacterStyle,0) THEN Title$=Title$+"<B"
  45.             IF FN BITTST(CharacterStyle,1) THEN Title$=Title$+"<I"
  46.             IF FN BITTST(CharacterStyle,2) THEN Title$=Title$+"<U"
  47.             IF FN BITTST(CharacterStyle,3) THEN Title$=Title$+"<O"
  48.             IF FN BITTST(CharacterStyle,4) THEN Title$=Title$+"<S"
  49.          State=VAL(MID$(BIN$(EnableFlags&),32-MenuItem,1))
  50.             Offset&=Offset&+4
  51.             MENU MenuNumber, MenuItem, State, Title$
  52.     UNTIL PEEK(MyPointer&+Offset&)=FALSE
  53.     Done=-1
  54.     END IF
  55.     MyHandle&=USR 7(MyPointer&)
  56.     CALL DETACHRESOURCE(MyHandle&)
  57. END FN=Done
  58.